package converters;
  
import javax.faces.component.UIComponent;  
import javax.faces.context.FacesContext;  
import javax.faces.convert.Converter;  
import javax.faces.convert.FacesConverter;

import domain.OrgBirimDAO;
  
@FacesConverter(value="birimConverter")
public class BirimConverter implements Converter {  
  
    public Object getAsObject(FacesContext facesContext, UIComponent component, String submittedValue) {  
    	OrgBirimDAO s = null;
			if (submittedValue.trim().equals("")) {  
			    return null;  
			} else { 
				s = new OrgBirimDAO(submittedValue);
			}
        return s;
    }  
  
    public String getAsString(FacesContext facesContext, UIComponent component, Object value) {  
    	if (value == null) {  
            return "";  
        }
    	String birimKodu = ((OrgBirimDAO) value).getBirimkodu();
    	if (birimKodu == null) {  
            return "";  
        } else {  
            return String.valueOf(birimKodu);  
        }  
    }  
}  